From e38ef591c4e08cc259d57c986a726fa66ac10f7e Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 19 Aug 2024 19:56:09 -0500 Subject: [PATCH] Give the component it's own CSS file --- MANIFEST.in | 1 + src/pgwui_sql/pgwui_sql.py | 4 ++++ src/pgwui_sql/static/pgwui_sql.css | 27 +++++++++++++++++++++++++++ src/pgwui_sql/templates/sql.mak | 7 +++++++ tests/test_pgwui_sql.py | 6 +++++- 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/pgwui_sql/static/pgwui_sql.css diff --git a/MANIFEST.in b/MANIFEST.in index 49cb29a..53186a6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,5 +5,6 @@ include .coveragerc include LICENSE.txt include Makefile include src/pgwui_sql/VERSION +include src/pgwui_sql/static/*.css include src/pgwui_sql/templates/*.mak include tox.ini diff --git a/src/pgwui_sql/pgwui_sql.py b/src/pgwui_sql/pgwui_sql.py index 2c67e3a..54bf21c 100644 --- a/src/pgwui_sql/pgwui_sql.py +++ b/src/pgwui_sql/pgwui_sql.py @@ -41,5 +41,9 @@ def includeme(config): '''Pyramid configuration for PGWUI_SQL ''' establish_settings(config) + config.add_static_view( + f'static/{PGWUI_COMPONENT}', + f'{PGWUI_COMPONENT}:static/', + cache_max_age=3600) config.add_route(PGWUI_COMPONENT, DEFAULT_SQL_ROUTE) config.scan() diff --git a/src/pgwui_sql/static/pgwui_sql.css b/src/pgwui_sql/static/pgwui_sql.css new file mode 100644 index 0000000..c40d47d --- /dev/null +++ b/src/pgwui_sql/static/pgwui_sql.css @@ -0,0 +1,27 @@ +/* Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/ + * + * This file is part of PGWUI_Common. + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this program. If not, see + * . + * + * Required style sheet for PGWUI programs. + * + * Karl O. Pinc + */ + +/* The SQL entry window. */ +.sqltext { height: 40em; + width: 80em; } + diff --git a/src/pgwui_sql/templates/sql.mak b/src/pgwui_sql/templates/sql.mak index b63ba17..3d548df 100644 --- a/src/pgwui_sql/templates/sql.mak +++ b/src/pgwui_sql/templates/sql.mak @@ -46,6 +46,13 @@ content="PostgreSQL Web User Interface, Interactive SQL execution" /> +<%block name="stylesheet_links"> + ${parent.stylesheet_links()} + + + <%block name="action_success">

Executed SQL without errors, from a file! diff --git a/tests/test_pgwui_sql.py b/tests/test_pgwui_sql.py index 355ae5b..f14720a 100644 --- a/tests/test_pgwui_sql.py +++ b/tests/test_pgwui_sql.py @@ -81,20 +81,24 @@ mock_establish_settings = testing.make_mock_fixture( # includeme() +mock_add_static_view = testing.late_instance_mock_fixture('add_static_view') mock_add_route = testing.late_instance_mock_fixture('add_route') mock_scan = testing.late_instance_mock_fixture('scan') @pytest.mark.unittest -def test_includeme(mock_establish_settings, mock_add_route, mock_scan): +def test_includeme(mock_establish_settings, mock_add_static_view, + mock_add_route, mock_scan): '''establish_settings, add_route, and scan are all called ''' with pyramid.testing.testConfig() as config: + mocked_add_static_view = mock_add_static_view(config) mocked_add_route = mock_add_route(config) mocked_scan = mock_scan(config) pgwui_sql.includeme(config) mock_establish_settings.assert_called_once() + mocked_add_static_view.assert_called_once() mocked_add_route.assert_called_once() mocked_scan.assert_called_once() -- 2.34.1